package com.woniuxy.oldmanapi.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.oldmanapi.entity.Consulter;
import com.woniuxy.oldmanapi.mapper.ConsulterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ConsultService {
    @Autowired
    ConsulterMapper consulterMapper;

    //查询咨询者信息
    public PageInfo<Consulter> selectConsulter(int now, int size, String cname) {
        PageHelper.startPage(now,size);
        List<Consulter> consulterList = consulterMapper.selectConsulterByName(cname);
        PageInfo<Consulter> pageInfo = new PageInfo<>(consulterList);
        return pageInfo;
    }

    //更新咨询者信息
    public void updateConsulter(Consulter consulter) {
        consulterMapper.updateByPrimaryKey(consulter);
    }

    //删除咨询者信息
    public void deleteConsulter(Consulter consulter) {
        consulterMapper.delete(consulter);
    }

    //新增咨询者信息
    public void insertConsulter(Consulter consulter) {
        consulterMapper.insert(consulter);
    }
}
